﻿Public Class frmTiepNhanHocSinh

    Private Sub frmTiepNhanHocSinh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cboLop.DataSource = LopBUS.SelectAll()
        cboLop.ValueMember = "MALOP"
        cboLop.DisplayMember = "TENLOP"
        dgvDSHS.DataSource = HocSinhBUS.SelectAll()
    End Sub

    Sub LoadDanhSach()
        dgvDSHS.DataSource = HocSinhBUS.SelectAll()
    End Sub

    Private Sub btnThem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThem.Click
        Dim hs = New HocSinhDTO
        hs.MAHOCSINH = txtMaHS.Text
        hs.TENHOCSINH = txtTenHS.Text
        hs.GIOITINH = IIf(rbNam.Checked, "Nam", "Nữ")
        hs.NGAYSINH = txtNgaySinh.Text
        hs.DIACHI = txtDiaChi.Text
        hs.SODT = txtSoDT.Text
        hs.EMAIL = txtEmail.Text
        hs.MALOP = cboLop.SelectedValue

        Dim re = HocSinhBUS.Them(hs)
        If re >= 1 Then
            MessageBox.Show("Thêm thành công")
        Else
            MessageBox.Show("Thêm thất bại")
        End If
        LoadDanhSach()
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtMaHS.Text = String.Empty
        txtTenHS.Text = String.Empty
        rbNam.Checked = True
        txtNgaySinh.Text = String.Empty
        txtDiaChi.Text = String.Empty
        txtEmail.Text = String.Empty
        txtSoDT.Text = String.Empty

    End Sub
End Class